<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="context-path" content="${pageContext.request.contextPath}">
    <title>编辑轮播图 - 体育商城后台</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/admin.css">
    <style>
        body {
            padding-top: 56px;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        .sidebar {
            min-height: calc(100vh - 56px);
            position: fixed;
            top: 56px;
            left: 0;
            width: 200px;
            z-index: 100;
            padding: 20px 0;
            box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
            background-color: #343a40;
        }
        .sidebar .nav-link {
            color: #ddd;
            padding: 0.5rem 1rem;
        }
        .sidebar .nav-link:hover {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.1);
        }
        .sidebar .nav-link.active {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.2);
        }
        .sidebar .nav-link i {
            margin-right: 8px;
        }
        .main-content {
            margin-left: 200px;
            padding: 20px;
            flex: 1;
        }
    </style>
</head>
<body>
    <jsp:include page="header.jsp" />
    
    <div class="container-fluid">
        <div class="row">
            <jsp:include page="sidebar.jsp" />
            
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 main-content">
                <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                    <h1 class="h2">编辑轮播图</h1>
                    <div class="btn-toolbar mb-2 mb-md-0">
                        <a href="${pageContext.request.contextPath}/admin/banner/list" class="btn btn-sm btn-outline-secondary">
                            返回列表
                        </a>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-body">
                        <form id="bannerEditForm" enctype="multipart/form-data">
                            <input type="hidden" name="id" value="${banner.id}">
                            
                            <div class="mb-3">
                                <label for="title" class="form-label">标题 <span class="text-danger">*</span></label>
                                <input type="text" class="form-control" id="title" name="title" value="${banner.title}" required>
                            </div>
                            
                            <div class="mb-3">
                                <label for="currentImage" class="form-label">当前图片</label>
                                <div class="mb-2">
                                    <img src="${banner.imageUrl}" alt="${banner.title}" style="max-width: 300px; max-height: 150px;">
                                </div>
                                <input type="hidden" name="imageUrl" value="${banner.imageUrl}">
                            </div>
                            
                            <div class="mb-3">
                                <label for="imageFile" class="form-label">上传新图片</label>
                                <input type="file" class="form-control" id="imageFile" name="imageFile" accept="image/*">
                                <div id="imagePreview" class="mt-2 d-none">
                                    <img src="" alt="图片预览" style="max-width: 300px; max-height: 150px;">
                                </div>
                                <div class="form-text">不上传则保持原图片不变</div>
                            </div>
                            
                            <div class="mb-3">
                                <label for="linkUrl" class="form-label">跳转链接</label>
                                <input type="text" class="form-control" id="linkUrl" name="linkUrl" value="${banner.linkUrl}">
                                <div class="form-text">如：/products?categoryId=1，可不填</div>
                            </div>
                            
                            <div class="mb-3">
                                <label for="sortOrder" class="form-label">排序</label>
                                <input type="number" class="form-control" id="sortOrder" name="sortOrder" value="${banner.sortOrder}" min="0">
                                <div class="form-text">数字越小排序越靠前</div>
                            </div>
                            
                            <div class="mb-3 form-check">
                                <input type="checkbox" class="form-check-input" id="status" name="status" value="1" ${banner.status == 1 ? 'checked' : ''}>
                                <label class="form-check-label" for="status">启用</label>
                            </div>
                            
                            <button type="submit" class="btn btn-primary">保存</button>
                            <a href="${pageContext.request.contextPath}/admin/banner/list" class="btn btn-secondary">取消</a>
                        </form>
                    </div>
                </div>
            </main>
        </div>
    </div>
    
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/admin/banner.js"></script>
</body>
</html> 